package com.gxuwz.eschool;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.gxuwz.eschool.bean.News;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class NewsActivity extends AppCompatActivity {
    ListView lv;
    SimpleAdapter simpleAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_news);
        lv = findViewById(R.id.new_list);
        simpleAdapter = new SimpleAdapter(
                NewsActivity.this,getData(),R.layout.news_new_item,
                new String[]{"title","time","from"},
                new int[]{R.id.new_item_title,R.id.new_item_time,R.id.new_item_from}
        );
        lv.setAdapter(simpleAdapter);
    }

    public void goBack(View v){
        this.finish();
    }

    private List<Map<String,Object>> getData() {
        String[] titles = {"2022级新生绑卡情况", "北校区断电情况", "水费、电费充值注意事项"};
        String[] froms = {"一卡通技术", "筑波技术", "一卡通技术"};
        String[] times = {"2024-03-12 09:12:23", "2023-05-11 09:12:23", "2022-09-01 09:12:23"};
        List<Map<String, Object>> list = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            Map map = new HashMap();
            map.put("title", titles[i]);
            map.put("time", times[i]);
            map.put("from", froms[i]);
            list.add(map);
        }
            return list;

    }

}